import QtQuick 2.9
import QtQuick.Controls 1.4

Rectangle {
    id:rect
    Rectangle{
        width: 322
        height: 242
        x:0
        y:0
        Image {
            id: image_0
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_0
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }

    Rectangle{
        width: 322
        height: 242
        x:322
        y:0
        Image {
            id: image_1
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_1
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }

    Rectangle{
        width: 322
        height: 242
        x:644
        y:0
        Image {
            id: image_2
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_2
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    Rectangle{
        width: 322
        height: 242
        x:966
        y:0
        Image {
            id: image_3
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_3
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    Rectangle{
        width: 322
        height: 242
        x:0
        y:242
        Image {
            id: image_4
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_4
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    Rectangle{
        width: 322
        height: 242
        x:322
        y:242
        Image {
            id: image_5
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_5
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    Rectangle{
        width: 322
        height: 242
        x:644
        y:242
        Image {
            id: image_6
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_6
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    Rectangle{
        width: 322
        height: 242
        x:966
        y:243
        Image {
            id: image_7
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_7
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    Rectangle{
        width: 322
        height: 242
        x:0
        y:484
        Image {
            id: image_8
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_8
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    Rectangle{
        width: 322
        height: 242
        x:322
        y:484
        Image {
            id: image_9
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_9
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    Rectangle{
        width: 322
        height: 242
        x:644
        y:484
        Image {
            id: image_10
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_10
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    Rectangle{
        width: 322
        height: 242
        x:966
        y:484
        Image {
            id: image_11
            source: ""
            width: 320
            height: 240
            x: 1
            y: 1
        }
        Label {
            id: label_11
            text: ""
            color: "red"
            font.family: "WenQuanYi Zen Hei"
            font.pointSize: 14
            font.bold: true
        }
    }
    /*Image {
        id: image_12
        source: "file:///D:/download/data/036-split/P036_0020_0.jpg"
        width: 320
        height: 240
    }
    Image {
        id: image_13
        source: "file:///D:/download/data/036-split/P036_0020_0.jpg"
        width: 320
        height: 240
    }
    Image {
        id: image_14
        source: "file:///D:/download/data/036-split/P036_0020_0.jpg"
        width: 320
        height: 240
    }
    Image {
        id: image_15
        source: "file:///D:/download/data/036-split/P036_0020_0.jpg"
        width: 320
        height: 240
    }*/

    function resize(value){
        if(value === 1){
            return;
        }
        var img_width = value*320;
        var img_height = value*240;
        var arr = rect.children;
        for(var i=0;i<3;i++){
            for(var j=0;j<4;j++){
                //console.log(value);
                arr[i*4+j].width = img_width+2;
                arr[i*4+j].height = img_height+2;
                arr[i*4+j].x = (img_width+2)*j;
                arr[i*4+j].y = (img_height+2)*i;
                var r_image = arr[i*4+j].children[0];
                //console.log(arr[i*4+j].x);
                r_image.width = img_width;
                r_image.height = img_height;
                r_image.x = 1;
                r_image.y = 1;
            }
        }
    }

    function set_picture(prefix, name){
        var name_list = name.split('.');
        for(var i=0;i<12;i++){
            var t;
            switch(i){
                case 0:t=image_0;break;
                case 1:t=image_1;break;
                case 2:t=image_2;break;
                case 3:t=image_3;break;
                case 4:t=image_4;break;
                case 5:t=image_5;break;
                case 6:t=image_6;break;
                case 7:t=image_7;break;
                case 8:t=image_8;break;
                case 9:t=image_9;break;
                case 10:t=image_10;break;
                case 11:t=image_11;break;
            }
            t.source = "file:///"+prefix+name_list[0]+'_'+i.toString()+'.jpg';
        }
    }
    function set_location(num){
        var arr = rect.children;
        for(var i=0;i<12;i++){
            arr[i].color = 'white';
        }
        arr[num].color = 'red';
    }

    function set_label(num, name){
        var t;
        switch(num){
            case 0:t=label_0;break;
            case 1:t=label_1;break;
            case 2:t=label_2;break;
            case 3:t=label_3;break;
            case 4:t=label_4;break;
            case 5:t=label_5;break;
            case 6:t=label_6;break;
            case 7:t=label_7;break;
            case 8:t=label_8;break;
            case 9:t=label_9;break;
            case 10:t=label_10;break;
            case 11:t=label_11;break;
        }
        t.text = name;
    }

    function set_label_empty(){
        label_0.text = "";
        label_1.text = "";
        label_2.text = "";
        label_3.text = "";
        label_4.text = "";
        label_5.text = "";
        label_6.text = "";
        label_7.text = "";
        label_8.text = "";
        label_9.text = "";
        label_10.text = "";
        label_11.text = "";
    }
}
